<template>
  <div style="padding: 0 15px;" v-loading="loading">
    <el-collapse-transition>
      <div v-show='listWrap'>
        <el-form :inline="true" :model="search" class="search" @keyup.enter.native="reList" style="height:auto">
          <!-- <el-form-item>
              <el-date-picker
              v-model="date"
              :clearable='false'
              type="daterange"
              range-separator="至"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              @change='timeChange'
              :picker-options="pickerOptions"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item> -->
          <el-form-item>
            <el-select v-model="search.eval_from_to" placeholder="请选择" @change="reList">
            <el-option
              v-for="item in options1"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          </el-form-item>
          <el-form-item>
            <el-select v-model="search.status" placeholder="请选择"  @change="reList">
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
          </el-form-item>
          <el-form-item>
            <el-input v-model="search.plan_title" placeholder="搜索评价计划" clearable prefix-icon="el-icon-search"
              @clear="reList" style="width:150px;"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="small" @click="reList()" title='点击搜索'>搜索</el-button>
            <el-button v-if="class_ids===''" @click="addPlan()" size="small" plain title='点击去新增评价计划'>新增评价计划</el-button>
          </el-form-item>
        </el-form>
        <el-table  style="width: 100%" :data="tableData" border align="center" show-overflow-tooltip highlight-current-row stripe table-layout='auto'>
          <el-table-column prop="plan_title" label="评价计划"></el-table-column>
          <el-table-column prop="eval_from_to" label="评价人/被评人" width="120" align="center"></el-table-column>
          <el-table-column prop="is_self_eval" label="是否支持自评"  width="120" align="center">
            <template slot-scope="scope">
              {{isYesStr[scope.row.is_self_eval]}}
            </template>
          </el-table-column>
          <el-table-column prop="is_edit_eval" label="可否修改"  width="80" align="center">
            <template slot-scope="scope">
              {{isYesStr[scope.row.is_edit_eval]}}
            </template>
          </el-table-column>
          <el-table-column prop="begin_time" label="开始日期" width="160"  align="center"></el-table-column>
          <el-table-column prop="end_time" label="结束日期" width="160"  align="center">
            <template slot-scope="scope">
              {{scope.row.end_time==null || scope.row.end_time ==''?"长期有效":scope.row.end_time}}
            </template>
          </el-table-column>
          <el-table-column prop="is_hidden"  width="80" label="评价属性"  align="center">
             <template slot-scope="scope">
              <span class="{stop:}">{{isHideStr[scope.row.is_hidden]}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="completion_ratio"  width="80"  label="完成状态"  align="center">
          </el-table-column>
        <el-table-column prop="status" label="计划状态" width="80"  align="center">
          <template slot-scope="scope">
              <!-- {{isStatusStr[scope.row.status]}} -->
               <!-- isStatusStr: {0: '停止', 1: '草稿', 2: '待发布', 3: '发布中'}, -->
              <span :class="{red:scope.row.status==1,green:scope.row.status==3,gray:scope.row.status==0}">{{isStatusStr[scope.row.status]}}</span>
            </template>
        </el-table-column>
        <el-table-column prop="create_user_name" label="创建人"  width="160" align="center"  show-overflow-tooltip></el-table-column>
        <el-table-column  fixed="right" label="操作" width="280" align="center">
           <template slot-scope="scope">
            <!-- {{scope.row.status}} -->
            <!-- <el-popconfirm title="确定发布吗？" :key="'pub' + scope.row.id" :ref="'war' + scope.row.id"  @confirm="handlePub(scope.row,2)"> -->
            <el-popconfirm title="确定发布吗？" :key="'pub' + scope.row.id" :ref="'war' + scope.row.id"  @confirm="handlePub(scope.row,2)">
              <el-link v-if="(scope.row.status==1 || scope.row.status == 0) && class_ids ==''" type="primary" slot="reference" size="small" :title="'发布'+scope.row.plan_title +'】'">发布</el-link>
            </el-popconfirm>

            <el-link v-if="(scope.row.status==3||scope.row.status==2) && class_ids ==''" type="primary" @click="handleStop(scope.row)"  size="small" :title="'停止【'+scope.row.plan_title +'】'">停止</el-link>
            <el-link v-if="scope.row.status!==1" type="primary" @click="handleStatistics(scope.row)"  size="small" :title="'查看【'+scope.row.plan_title +'】统计信息'">统计</el-link>
            <el-popconfirm title="确认提醒吗？" :key="'war' + scope.row.id" :ref="'war' + scope.row.id" @confirm="handleWarn(scope.row,1)">
              <el-link v-if="scope.row.status==3&&scope.row.finish!==scope.row.unfinish"  type="primary" size="small" slot="reference" :title="'提醒【'+scope.row.plan_title +'】'">未完成提醒</el-link>
            </el-popconfirm>
            <el-link v-if="scope.row.status==3 && scope.row.finish===scope.row.unfinish" :disabled='scope.row.finish===scope.row.unfinish' type="primary" size="small" slot="reference" :title="'【'+scope.row.plan_title +'】该计划已完成无需提醒'">未完成提醒</el-link>
            <el-link v-if="(scope.row.status==0||scope.row.status==1 ) && class_ids ==''"  type="primary" @click="handleEdit(scope.row)"  size="small" :title="'编辑【'+scope.row.plan_title +'】'">编辑</el-link>

            <el-popconfirm title="确定删除吗？" :key="'del' + scope.row.id" :ref="'del' + scope.row.id" @confirm="handleDel(scope.row)">
              <el-link v-if="scope.row.status!==3 && class_ids ==''"  type="danger" slot="reference" size="small" :title="'删除【'+scope.row.plan_title +'】'" >删除</el-link>
            </el-popconfirm>
           </template>
        </el-table-column>
       </el-table>
        <!-- 分页 -->
        <el-pagination :currentPage=search.pageNo :page-size=search.pageSize :page-sizes="[10, 20,40, 50, 100]" :hide-on-single-page="allTotal==0"
          layout="total, sizes, prev, pager, next, jumper" :total="allTotal" @size-change="handleSizeChange"
          @current-change="handleCurrentChange">
        </el-pagination>
      </div>
    </el-collapse-transition>
    <!-- :hide-on-single-page="allTotal<20" width="40%" v-loading="editLoading" append-to-body lock-scroll destroy-on-close-->
    <!-- 发布提醒窗口 -->
    <el-dialog :title="publishSureText+'推送设置'" :visible.sync="dialogInfoVisible" append-to-body lock-scroll destroy-on-close width="30%">
      <div class="checkSendObj" v-loading="dialogloading">
        <div class="formView">
          <el-divider content-position="center"></el-divider>
          <el-form :model="form" :rules="rules" ref="ruleForm" label-width="" class="pubWrap">
            <el-form-item label="模版推送代管班主任" v-if="showClassLeader">
              <el-radio-group v-model="form.is_send_bzr" active-color="#409EFF" inactive-color="#cccccc" active-value='1' inactive-value='0'>
                <el-radio label="1">推送</el-radio>
                <el-radio label="0">不推送</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="   模版推送填写人">
              <el-radio-group v-model="form.is_send_evaluator" active-color="#409EFF" inactive-color="#cccccc" active-value='1' inactive-value='0'>
                <el-radio label="1">推送</el-radio>
                <el-radio label="0">不推送</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
          <el-divider content-position="center"></el-divider>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" v-loading="dialogloading" @click="toPub">确认{{publishSureText}}</el-button>
        <el-button @click="close">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: 'planList',
  data () {
    return {
      tableData: [],
      // 班级详情搜索
      loading: false,
      listWrap: true,
      // 总条数
      allTotal: 0,
      // 是否
      isYesStr: {1: '是', 0: '否'},
      // 是否匿名
      isHideStr: {1: '匿名', 0: '实名'},
      isStatusStr: {0: '停止', 1: '草稿', 2: '待发布', 3: '发布中'},
      search: {
        'pageNo': 1,
        'pageSize': 10,
        'plan_title': '',
        'eval_from_to': '',
        'begin_time': '',
        'end_time': '',
        'status': '',
        'class_ids': ''
      },
      options1: [
      {
          value: '',
          label: '评价人/被评价人'
      },
      {
          value: '学生/教师',
          label: '学生/教师'
      },
      {
          value: '教师/教师',
          label: '教师/教师'
      }
      ],
      // 0停止 1草稿 2待发布 3发布中
      options2: [
      {
          value: '',
          label: '全部状态'
      },
      {
          value: '0',
          label: '停止'
      },
      {
          value: '1',
          label: '草稿'
      },
      {
          value: '2',
          label: '待发布'
      },
      {
          value: '3',
          label: '发布中'
      }
      ],
      date: [],
      dialogInfoVisible: false, // 编辑模板窗口
      // 所有班级数组
      allGrade: [],
      // 所有年级班级Obj
      allClass: {},
      getNowAllClass: [],
      // 发布
      form: {
        'plan_id': '',
        'is_send_bzr': '1',
        'is_send_evaluator': '1'
      },
      rules: {
        is_send_bzr: [
          {
            required: true,
            message: '请选择横板推送代管班主任：'
          }
        ],
        is_send_evaluator: [
          {
            required: true,
            message: '请选择横板推送填写人'
          }
        ]
      },
      flagTime: '',
      publishSureText: '发布',
      // 需要发布或者提醒的计划
      publishObj: {},
      showClassLeader: false,
      // 窗口加载
      dialogloading: false,
      // 班主任标识
      class_ids: '',
      // 搜索的日期
      pickerOptions: {
        // 最长选择2个月
        onPick: ({maxDate, minDate}) => {
            this.flagTime= minDate.getTime()
            if (maxDate) {
              this.flagTime= ''
            }
          },
        disabledDate: (time) => {
          if (this.flagTime!== '') {
            const one = 30 * 24 * 3600 * 1000 * 2
            const minTime = this.flagTime- one
            const maxTime = this.flagTime+ one
            return time.getTime() < minTime || time.getTime() > maxTime
          }
        }
      }
    }
  },
  mounted() {
      // this.restaurants = this.loadAll()
  },
  watch: {
  },
  created () {
    // let _this = this
    // 设置默认查询日期：获取当前日期
    // 结束
    // var today = new Date()
    // var year = today.getFullYear()// 获取年份
    // var month = today.getMonth() + 1// 获取月份
    // var day = today.getDate()// 获取日期
    // // 一个月前
    // var yesterday = new Date(today.getTime() - 30 * 24 * 60 * 60 * 1000)
    // this.search.begin_time = yesterday.getFullYear() + '-' + (yesterday.getMonth() + 1) + '-' + yesterday.getDate()
    // this.search.end_time = year + '-' + month + '-' + day
    // this.date = [this.search.begin_time + ' 00:00:00', this.search.end_time + ' 23:59:59']

    // 判断权限
    let rlids = sessionStorage.getItem('rlids')
    let purview = null
    if (typeof rlids !== 'object' && rlids !== null) {
         purview = rlids.substring(0, rlids.length - 1).split(',')
    } else {
         purview = rlids
    }
    // 超级管理员99、智慧评价管理员56能够查看全校所有年级班级下的学生；班主任能查看授课班级的学生。
    if (purview.indexOf('56') < 0 && (sessionStorage.identity ==='99'||purview.indexOf('99') < 0) && purview.indexOf('4') < 0) {
        this.$alert('您没有智慧评价的访问权限！', {
          confirmButtonText: '确定',
          closeOnHashChange: !1,
          callback: action => {
            window.location.href = '#41'
          }
        })
    }
    // 评价管理员，超级管理员
    if (purview.indexOf('56') < 0 && (sessionStorage.identity !=='99'|| purview.indexOf('99')< 0)) {
       this.dealLocalData()
    }
    this.list()
    sessionStorage.removeItem('IAS_plan_id')
  },
  computed: {
  },
  methods: {
    // 只能输入小数和整数35-42
    checkedNumber(value, obj) {
      const oldValue=value
      value = value.replace(/[^\d|.]/g, '')
      let dealValue = value < 35 || value > 42.9 ? '' : value
      this.allTemperature[obj] = dealValue
      if (value === ''&&oldValue!=='') {
        // this.$message('只能输入35-42的数字', '提示', { type: 'warning' })
        this.$message({
          message: '只能输入35-42.9的数字',
          type: 'warning'
        })
      } else {
        this.list()
      }
    },
       // 自适应表格列宽
    setWidth(str, tableData) {
      // str为该列的字段名(传字符串);tableData为该表格的数据源(传变量);
      str = str + ''
      let columnContent = ''
      let maxObj = null
      if (!tableData || !tableData.length || tableData.length === 0 || tableData === undefined) {
        return
      }
      if (!str || !str.length || str.length === 0 || str === undefined) {
        return
      }
       let nowL = str.replace('key', '')
        // 获取该列中最长的数据(内容)
        let index = 0
        for (let i = 0; i < tableData.length; i++) {
          if (tableData[i][nowL][str] === null) {
            return
          }
          const nowTemp = tableData[i][nowL][str].value || tableData[i][nowL][str].title + ''
          const maxTemp = (maxObj ? maxObj.value:'') || tableData[index][nowL][str].value || tableData[index][nowL][str].title + ''
          if (nowTemp.length > maxTemp.length) {
            // index = i
            maxObj = tableData[i][nowL][str]
          } else {
            maxObj = maxObj ||tableData[index][nowL][str] || tableData[index][nowL][str]
          }
        }
      console.log(maxObj.value)
      if (maxObj.type === 7) {
        for (let a = 0, b = maxObj.value.split(',').length; a < b; a++) {
          columnContent += '刘9'
        }
      } else {
        columnContent = maxObj.value || maxObj.title + ''
      }
      // 以下分配的单位长度可根据实际需求进行调整
      let flexWidth = 0
      for (const char of columnContent) {
        if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) {
          // 如果是英文字符，为字符分配8个单位宽度
          flexWidth += 12
        } else if (char >= '\u4e00' && char <= '\u9fa5') {
          // 如果是中文字符，为字符分配15个单位宽度
          flexWidth += 18
        } else {
          // 其他种类字符，为字符分配8个单位宽度
          flexWidth += 9
        }
      }
      if (flexWidth < 100) {
        // 设置最小宽度
        flexWidth = 100
      }
      return flexWidth + 'px'
    },
    timeChange(e, b) {
      if (typeof e !== 'object') {
         this.data = [e, e]
      }
      this.search.pageNo=1
      this.list()
    },
    // 本地数据生成班主任的班级ids
    dealLocalData(okFun) {
      const mapBZR = JSON.parse(sessionStorage.getItem('mapBZR'))
      const classIds=[]
      mapBZR.map(item => {
        classIds.push(item.clas_id)
      })
      if(classIds.length>0){
        this.class_ids=classIds.join(',')
      }else{
        this.class_ids='-1'
      }
      if (okFun) { okFun() }
    },
    // 重置搜索条件
    reList () {
      this.search.pageNo = 1
      this.list()
    },
    // 获取计划列表
    async list () {
       this.loading = true
      //  this.search.begin_time = this.date[0]
      //  this.search.end_time = this.date[1]
       this.search.class_ids=this.class_ids

      const res = await this.$api.plan.list.get(this.search)
      debugger
      if (res.code === 200) {
        this.tableData = res.data.data.map(item=>{
          const finish=item.completion_ratio.split('/').map(Number)
          item.unfinish=finish[0]
          item.finish=finish[1]
          return item
        })
        console.log(this.tableData)
        this.loading = false
        // 分页
        this.allTotal = res.data.total
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 获取所有年级班级
    async getAllClass (okFun) {
      this.loading = true
      const res = await this.$api.plan.getAllClass.get(this.search)
      if (res.code === 200) {
        let dealData = []
        let dealAllClass = []
        let allGClassId = []
        res.data.depData.map(item => {
          if (item % 10 !== 0 && item.clasList.length !== 0) {
           let allClassId = []
           let allClass = []
           item.clasList.map(item => {
              let obj = {
                    clas_id: item.clas_id,
                    clas_name: item.clas_name
                  }
                  allClassId.push(item.clas_id)
                  allClass.push(obj)
                  allGClassId.push(item.clas_id)
           })
           item.clasList = allClass
           item.clasList.unshift({
                    clas_id: allClassId.join('_'),
                    clas_name: '全部班级'
                  })
            dealAllClass[item.grade_id] = item.clasList
            dealData.push(item)
          }
        })

        this.allGrade = dealData
        this.allGrade.unshift({
          grade_id: 1000000,
          grade_name: '全部年级',
          clasList: [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
        })
        dealAllClass[1000000] = [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
        this.allClass = dealAllClass
        this.search.grade = 1000000
        console.log(dealData)
        this.search.search_class = allGClassId.join('_')
        this.getNowAllClass = [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
        // console.log(dealData)
        if (okFun) { okFun() }
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    async getGradeClass (gradeIds, okFun) {
      this.loading = true
      const res = await this.$api.plan.getAllClass.get({})
      if (res.code === 200) {
        let dealData = []
        let dealAllClass = []
        let allGClassId = []
        res.data.depData.map(item => {
          if (item % 10 !== 0 && item.clasList.length !== 0) {
            // 只有自己管理理论的年级才显示
            if (gradeIds.includes(item.grade_id)) {
                let allClassId = []
                let allClass = []
                item.clasList.map(item => {
                    let obj = {
                          clas_id: item.clas_id,
                          clas_name: item.clas_name
                        }
                        allClassId.push(item.clas_id)
                        allClass.push(obj)
                        allGClassId.push(item.clas_id)
                })

                item.clasList = allClass
                item.clasList.unshift({
                          clas_id: allClassId.join('_'),
                          clas_name: '全部班级'
                        })
                  dealAllClass[item.grade_id] = item.clasList
                  dealData.push(item)
            }
          }
        })

        this.allGrade = dealData
        this.allGrade.unshift({
          grade_id: 1000000,
          grade_name: '全部年级',
          clasList: [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
        })
        dealAllClass[1000000] = [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
        this.allClass = dealAllClass
        this.search.grade = 1000000
        this.search.search_class = allGClassId.join('_')
        this.getNowAllClass = [{
            clas_id: allGClassId.join('_'),
            clas_name: '全部班级'
          }]
          if (okFun) { okFun() }
      } else {
        this.loading = false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    gradeChange(val) {
      this.getNowAllClass = this.allClass[val]
      this.search.search_class = this.allClass[val][0].clas_id
      this.search.pageNo = 1
      this.list()
    },
    // // 表格内开关事件
    // async changeSwitch (val, row) {
    //   // 1.还原数据
    //   row.open_btn = row.open_btn === '1' ? '0' : '1'
    //   // 2.执行加载
    //   row.loading = true
    //   const res = await this.$api.plan.switch.post({ id: row.id, open_btn: val })
    //   if (res.code === 200) {
    //     delete row.loading
    //     row.open_btn = val
    //     // this.$refs.table.refresh()
    //     this.$message.success(`操作成功:模板【${row.template_name} 】已${Number(val) === 0 ? '关闭' : '开启'}`)
    //   } else {
    //     row.is_using = val === '1' ? '0' : '1'
    //     this.$alert(res.message, '提示', { type: 'error' })
    //   }
    // },
    // 分页操作-修改显示页数-每页显示指定条数
    handleSizeChange (e) {
      this.search.pageNo = 1
      this.search.pageSize = e
      this.list()
    },
    // 分页操作-跳转到指定页 跳转到指定页数
    handleCurrentChange (e) {
      this.search.pageNo = e
      this.list()
    },
    // 格式化参数【下载】下载用
    parseParams (data) {
      try {
        let tempArr = []
        for (let i in data) {
          let key = encodeURIComponent(i)
          let value = encodeURIComponent(data[i])
          tempArr.push(key + '=' + value)
        }
        let urlParamsStr = tempArr.join('&')
        return urlParamsStr
      } catch (err) {
        return ''
      }
    },
    addPlan() {
      sessionStorage.IASStep=0
       this.$parent.$parent.editTemplate = null
      this.$parent.$parent.activeName = 'tabs1Flag'
      this.$parent.$parent.nowName = '新建模板'
      window.location.href='#x42'
    },
    // 下载模板或者Excel
    async downFile (type) {
      // var str = this.nowPlan.plan_name + (type === 2 ? '详情' : '个性化收费模板') + new Date().toLocaleString().replace(/[/\s:]/g, '') + '.xlsx'
      const parameter = {
        'org_id': sessionStorage.org_id,
        'token': sessionStorage.token,
        'udid': sessionStorage.udid
        // 'fileName': str
      }
      const downParameter = Object.assign(parameter, this.searchParameter())
      // 原始写法 新的是以流的方式下载，本地生成文件
      window.location.href = (type === 1 ? this.$api.plan.downList.url : this.$api.plan.downImg.url) + '?' + this.parseParams(downParameter)
      // var url = type === 1 ? this.$api.planDetail.downTemplate.down(downParameter) : this.$api.planDetail.downExcel.down(downParameter)
      // const res = await url
    },
    // 选择excle格式判断
    getFile (event, b) {
      if (event !== '' && !event.includes('.xlsx')) {
        document.getElementById('upload-file').value = ''
        this.$alert('目前仅支持excel2007及更高版本的.xlsx格式文件！', '提示', { type: 'warning' })
        return false
      }
    },
    // 弹出窗口 日期相关操作++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // 关闭预览窗口
    close (e, info) {
      this.dialogInfoVisible = false
    },
    // 关闭预览窗口 提示
    handleClose (done) {
      this.$confirm('确认要关闭编辑窗口吗？')
        .then(_ => {
          done()
        })
        .catch(_ => { })
    },
    // 输入校验 文档：校验文字<>& {} |*=;%  单行文本框禁止输入英文特殊字符<>&{}|*=;%
    checkText (string) {
      // const pattern = /[`~!@#$^\-&*()=|{}':;',\\\[\]\.<>\/?~！@#￥……&*（）——|{}【】'；：""'。，、？\s]/g
      const pattern = /[`<>& {} |*=;%\s]/g
      const str = string.replace(pattern, '')
      this.dialogForm.plan_name = str
    },
    // A 数组 是否包含B数组
    arrayIncludes (arr1, arr2) {
      return arr2.every(val => arr1.includes(val))
    },
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // 预览模板
    async handleView (e, info) {
      this.dialogInfoVisible = true
    },
    // 删除计划
    async handleDel (info) {
      //  this.$confirm('删除模板会同时删除相关的全部数据，确认要删除吗?', '提示', {
      //    confirmButtonText: '确定',
      //    cancelButtonText: '取消',
      //    type: 'warning'
      //  }).then(async () => {
      const delPr = { plan_id: info.id }
      const res = await this.$api.plan.del.post(delPr)
      if (res.code === 200) {
          this.list()
          this.$alert('计划已删除！', '提示', { type: 'success', closeOnHashChange: !1 })
      } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
      //  }).catch(() => {
      //  })
    },
    // 计划发布
    handlePub(obj) {
      // 是否显示班主任提醒
     if (obj.eval_from_to === '学生/教师') {
       this.showClassLeader=true
     }
      this.form.type = 2
      this.form.plan_id = obj.id
      this.publishObj=obj
      this.publishSureText='发布'
      this.dialogInfoVisible=true
    },
    // 计划提醒
    //@type  2发布 1提醒
    handleWarn(plan,type) {
      debugger
      // 是否显示班主任提醒
      if (plan.eval_from_to === '学生/教师') {
       this.showClassLeader=true
     }
      this.form.plan_id = plan.id
      this.form.type = type
      this.publishSureText='提醒'
      // if(type===2){
      //   this.dialogInfoVisible=true
      // }else{
        this.toPub ()
      //}
      
    },
    // 计划 发布OR提醒
    async toPub () {
      debugger
      if (this.showClassLeader) {
         this.form.is_send_bzr=''
         this.form.class_ids=this.class_ids
      }
      // type 1提醒 2发布
      const type=this.form.type
      this.dialogloading = true
      const res = (type ===1? await this.$api.plan.remind.post(this.form): await this.$api.plan.publish.post(this.form))
      this.dialogloading = false
      if (res.code === 200) {
        if (type===1) {
          this.$alert('提醒已发送！', '提示', { type: 'success', closeOnHashChange: !1 })
          this.dialogInfoVisible=false
        } else {
          this.list()
          this.$alert('发布成功！', '提示', { type: 'success', closeOnHashChange: !1 })
          this.dialogInfoVisible=false
        }
       } else {
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 计划停止
    async handleStop(info) {
      this.loading=true
      const stopParameters = {plan_id: info.id}
      const res = await this.$api.plan.stop.post(stopParameters)
      if (res.code === 200) {
         this.list()
         this.$alert('计划已停止！', '提示', { type: 'success', closeOnHashChange: !1 })
      } else {
        this.loading=false
        this.$alert(res.message, '提示', { type: 'error', closeOnHashChange: !1 })
      }
    },
    // 计划统计
    handleStatistics(obj) {
       const isAdmin=this.class_ids===''?1:0
      sessionStorage.IASStep=0
      window.location.href='#x43?id='+obj.id+'&num='+obj.completion_ratio+'&admin=' + isAdmin
    },
    // 计划编辑
    handleEdit (obj) {
      sessionStorage.IASStep=0
      window.location.href='#x42?id='+obj.id
    },
    toFirst (isEdit, obj) {
      this.$parent.$parent.activeName = 'tabs1Flag'
      this.$parent.$parent.nowName = isEdit ? '编辑模板' : '新建模板'
      this.$parent.$parent.tabsArr.tabs1Flag = true
      this.$parent.$parent.tabsArr.tabs2Flag = false
      this.$parent.$parent.tabsArr.tabs3Flag = false
    },
    toThird () {
      this.$parent.$parent.activeName = 'tabs3Flag'
      this.$parent.$parent.nowName = '落款设置'
      this.$parent.$parent.tabsArr.tabs3Flag = true
      this.$parent.$parent.tabsArr.tabs2Flag = false
      this.$parent.$parent.tabsArr.tabs1Flag = false
    }

  }
}
</script>
<style>
#app {
  font-family: Helvetica, sans-serif;
  text-align: center;
}

.el-table td,
.el-table th {
  padding: 5px 0;
  font-size: 14px;
}

.el-table td .el-button {
  padding: 8px 0px;
}

.el-link {
  margin-right: 10px;
}

.el-table__empty-block {
  max-height: 99px;
}

.el-textarea .el-input__count {
  background: none;
  bottom: -36px;
}

.el-dialog__body {
  padding: 0 30px;
  border: 1px #fff solid;
}

.checkSendObj .el-checkbox-group {
  margin-left: 21px;
  display: flex;
}

.search {
  background: #fbfafa;
  padding: 10px 12px 12px 12px;
  min-height: 30px;
  height: 36px;
  overflow: hidden;
}

.search .el-form-item {
  margin-bottom: 0;
}

.search .el-range-editor.el-input__inner {
  padding: 0px 10px;
  margin-top: 0px;
}

.el-pagination {
  padding: 18px 0px;
}

.checkSendObj .el-form-item__content {
  padding-left: 20px;
}

.search .el-form-item__content {
  padding-left: 0;
}
.search .el-range-editor.el-input__inner{
  margin-top: 5px;
}
.el-popover {
  max-width: 240px;
}

.el-popconfirm__main {
  padding: 5px 0;
}

body {
  overflow: auto;
  background-color: #fff;
}

.fileInput input {
  border: none;
}

/* 统计信息 */
.echarsWrap {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  flex-direction: row;
  margin-bottom: 15px;
  position: relative;
  padding: 20px 20px 0px 20px;
}

.echarsWrap legend {
  color: #496f8f;
  font-weight: bold;
}

.echarsWrap fieldset {
  margin-left: 15px;
  background-image: -webkit-linear-gradient(330deg, #fbfdff, #e1e8ef);
  background-image: -o-linear-gradient(330deg, #fbfdff, #e1e8ef);
  background-image: linear-gradient(120deg, #fbfdff, #e1e8ef);
  background-size: cover;
  border-radius: 5px;
  overflow: hidden;
  padding: 0 40px 0px 20px;
  position: relative;
}

.oneEcharsShow .oneEcharsNum {
  font-size: 24px;
  font-family: "sans-serif";
  font-weight: bold;
  line-height: 44px;
  text-align: center;
  height: 48px;
}

.planTitleWrap .planTitle {
  font-weight: bold;
  font-size: 16px;
}

.echarsWrap .oneEcharsTitle {
  font-size: 12px;
  position: absolute;
  right: 20px;
  top: 20px;
}

.el-table .cell {
  line-height: 24px;
  transform: translate3d(0, 0, 0);
}

.el-picker-panel__footer button:first-child {
  display: none;
}

.el-table__fixed-right {
  min-height: 75px;
}
.el-image-viewer__actions,.el-image-viewer__close {
  overflow: hidden;
}
.imgList {
  display: inline-flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    text-align: center;
    overflow: hidden;
}
.imgList img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: zoom-in;
}
.el-input--suffix .el-input__inner {
  padding-right: 6px;
}
.el-date-editor--daterange.el-input__inner {
  width: 280px;
}
.el-form--inline .el-form-item {
  margin-right: 2px;
}
.el-image-viewer__next, .el-image-viewer__prev,.el-image-viewer__close{
  display: -webkit-inline-box;
  overflow: hidden;
}
.temperature .el-input--suffix .el-input__suffix {
  top: -5px;
}
.temperature .el-input--suffix  .el-input-group__prepend .el-input__suffix {
  top: 5px;
}
.el-input-group__prepend {
  background: #fff;
}

.autoWidth {
  min-width: 120px;
  text-align: start;
}
.autoWidth .el-input__prefix {
  position: relative;
  box-sizing: border-box;
  border: 1px solid #ffffff00;
  padding: 0 40px;
  height: 40px;
  line-height: 40px;
  color: #606266;
  left: 0;
  visibility: hidden;
}
/* .autoWidth .el-input__inner {
  position: absolute;
} */
.red {
  color: #f30;
}
.green {
  color: rgb(18, 187, 69);
}
.green {
  color:gray
}
.pubWrap .el-form-item__label{
  min-width:140px;
}
</style>
